$(".i-checks").iCheck({
    checkboxClass: "icheckbox_square-green",
    radioClass: "iradio_square-green",
});

/*
* 单条编辑
* */
function bian(e) {
    var id = $("#i" + e).html()
    var name = $("#n" + e).html()
    var valuer = $("#v" + e).html()
    var memo = $("#m" + e).html()
//            console.log(id,name,valuer,memo)
    $(".nn").remove()
    $(".mm").attr("style", "")

    $("#n" + e + ",#v" + e + ",#m" + e + ",#o" + e).attr("style", "display:none")
    $("#i" + e).after("<td id='nn" + e + "' class='nn'><input type='text' name='name' value=" + name + "></td>" +
        "<td id='vv" + e + "' class='nn'><input type='text' name='valuer' value=" + valuer + "></td>" +
        "<td id='mm" + e + "' class='nn'><input type='text' name='memo' value=" + memo + "></td>" +
        "<td id='oo" + e + "' class='nn'>" +
        "<button id='q" + e + "' onclick='que(" + e + ")' class='btn btn-outline btn-xs btn-default'>确定</button>" +
        "<button id='x" + e + "' onclick='qu(" + e + ")' class='btn btn-outline btn-xs btn-default'>取消</button>" +
        "</td>")
}

function qu(e) {
    $("#nn" + e + ",#vv" + e + ",#mm" + e + ",#oo" + e).remove()
    $("#n" + e + ",#v" + e + ",#m" + e + ",#o" + e).attr("style", "")
}

/*
* 单条删除
* */
function shan(e) {
    $.ajax({
        url: "./del",
        data: "id=" + e,
        type: "post",
        dataType: "json",
        success: function (e) {
            layer.msg(e);
            setTimeout(function () {
                history.go(0)
            }, 1000);
        }
    })
}

//判断内容是否为空
function que(e) {
    var id=e;
    var name = $.trim($("input[name='name']").val());
    var valuer = $.trim($("input[name='valuer']").val());
    var memo = $.trim($("input[name='memo']").val());

    if (name == '') {
        layer.msg('请填写配置新名称');
        return false;
    }

    if (valuer == '') {
        layer.msg('请填写配置新信息');
        return false;
    }
    //ajax异步提交数据
    $.ajax({
        url: GV.system_siteconfig,
        type: 'post',
        data: {'id':id,'name': name, 'valuer': valuer, 'memo': memo},
        success: function (data) {
                // alert(data.info)
           if(data.status == 111){
               layer.msg(data.info);
                setTimeout(function(){
                    history.go(0)
                },1000);
           }else{
               layer.msg(data.info);
               setTimeout(function(){
                   history.go(0)
               },1000);
           }
        }
    });
}
